﻿namespace Swimj.DataCore
{
    public partial interface IRepository<TEntity, in TKey>
        where TEntity : class, new()
        where TKey : struct
    {
        IUnitOfWork UnitOfWork { get; }

        bool Insert(TEntity entity);

        Task<bool> InsertAsync(TEntity entity);

        bool BatchInsert(IEnumerable<TEntity> entities);

        Task<bool> BatchInsertAsync(IEnumerable<TEntity> entities);

        bool Update(TEntity entity);

        Task<bool> UpdateAsync(TEntity entity);

        bool BatchUpdate(IEnumerable<TEntity> entities);

        Task<bool> BatchUpdateAsync(IEnumerable<TEntity> entities);

        bool Delete(TEntity entity);

        Task<bool> DeleteAsync(TEntity entity);

        bool BatchDelete(IEnumerable<TEntity> entities);

        Task<bool> BatchDeleteAsync(IEnumerable<TEntity> entities);

        IEnumerable<TEntity> QueryAll();

        Task<IEnumerable<TEntity>> QueryAllAsync();

        IEnumerable<TEntity> QueryAllByOrder(string order, string sort);

        Tuple<IEnumerable<TEntity>, int> QueryAllByPage(int pageIndex, int pageSize);

        Tuple<IEnumerable<TEntity>, int> QueryAllByOrderPage(string order, string sort,
            int pageIndex, int pageSize);

        IEnumerable<TEntity> QueryFilter(ConditionCollection conditions);

        IEnumerable<TEntity> QueryFilterByOrder(ConditionCollection conditions,
            string order, string sort);
    }
}